package com.xzz.tree;

/**
 * @author: hhz
 * @create: 2021-12-31 11:50
 * 104. 二叉树的最大深度
 * 剑指 Offer 55 - I. 二叉树的深度
 *
 **/
public class MaxDepth {

    public static int maxDepth(TreeNode root) {
        if(root==null){
            return 0;
        }
        int leftDepth = maxDepth(root.left);
        int rightDepth = maxDepth(root.right);
        return rightDepth>leftDepth?rightDepth+1:leftDepth+1;
    }
}
